home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1994 November / macformat-018.iso / Utility Spectacular / Developer / halma-12-c / Halma ƒ / Shell ƒ / graphics.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-07-26  |  16.7 KB  |  521 lines  |  [TEXT/KAHL]

  1. /**********************************************************************\
  2.  
  3. File:        graphics.c
  4.  
  5. Purpose:    This module handles opening/closing/updating all windows:
  6.             this includes manipulating offscreen GWorlds & bitmaps
  7.             for fun and profit.
  8.  
  9. This program is free software; you can redistribute it and/or modify
  10. it under the terms of the GNU General Public License as published by
  11. the Free Software Foundation; either version 2 of the License, or
  12. (at your option) any later version.
  13.  
  14. This program is distributed in the hope that it will be useful,
  15. but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17. GNU General Public License for more details.
  18.  
  19. You should have received a copy of the GNU General Public License
  20. along with this program in a file named "GNU General Public License".
  21. If not, write to the Free Software Foundation, 675 Mass Ave,
  22. Cambridge, MA 02139, USA.
  23.  
  24. \**********************************************************************/
  25.  
  26. #include "graphics.h"
  27. #include "about.h"
  28. #include "about MSG.h"
  29. #include "help.h"
  30. #include "dialogs.h"
  31. #include "error.h"
  32. #include "menus.h"
  33. #include "environment.h"
  34. #include "prefs.h"
  35. #include "util.h"
  36. #include "program globals.h"
  37.  
  38. /* internal global variables for use by graphics.c only */
  39. static    ExtendedWindowDataHandle    gTheWindowData[NUM_WINDOWS];
  40. static    Rect        gBoundsRect[NUM_WINDOWS];        /* rectangle of offscreen bitmap */
  41. static    Rect        gMainScreenBounds;                /* bounds of main monitor */
  42. static    GWorldPtr    gTheGWorld[NUM_WINDOWS];        /* offscreen graphics world */
  43. static    Ptr            gBWBitMap[NUM_WINDOWS];            /* offscreen bitmap for B/W machines */
  44. static    GrafPort    gBWGrafPort[NUM_WINDOWS];        /* offscreen grafport "  "     "     */
  45. static    GrafPtr        gBWGrafPtr[NUM_WINDOWS];        /* offscreen grafptr  "  "     "     */
  46. static    GWorldPtr    currentGWorld;
  47. static    GDHandle    currentGDHandle;
  48.  
  49. Boolean InitTheGraphics(void)
  50. {
  51.     short            i,j;
  52.     
  53.     GetMainScreenBounds();
  54.     
  55.     for (i=0; i<NUM_WINDOWS; i++)
  56.     {
  57.         /* nothing is inited; if there's an error later on, we'll know how much to */
  58.         /* clean up in ShutDownTheGraphics() */
  59.         gTheGWorld[i]=(GWorldPtr)0L;
  60.         gTheWindowData[i]=(ExtendedWindowDataHandle)0L;
  61.     }
  62.     
  63.     for (i=0; i<NUM_WINDOWS; i++)
  64.     {
  65.         gTheWindowData[i]=(ExtendedWindowDataHandle)NewHandle(sizeof(ExtendedWindowDataRec));
  66.         if (gTheWindowData[i]==0L)                            /* return if error */
  67.             return FALSE;
  68.         
  69.         (**(gTheWindowData[i])).offscreenNeedsUpdate=TRUE;    /* offscreen not inited */
  70.         (**(gTheWindowData[i])).theWindowPtr=0L;            /* window ptr not inited */
  71.         (**(gTheWindowData[i])).windowIndex=i;                /* so we can retrieve it O(1) */
  72.         (**(gTheWindowData[i])).windowDepth=
  73.             (**(gTheWindowData[i])).maxDepth=1;                /* init at B/W */
  74.         (**(gTheWindowData[i])).isColor=FALSE;                /* init to grayscale */
  75.         for (j=0; j<MAX_TE_HANDLES; j++)
  76.             (**(gTheWindowData[i])).hTE[j]=0L;
  77.         HLockHi((Handle)gTheWindowData[i]);
  78.     }
  79.     
  80.     /* set window dispatch routines */
  81.     SetIndDispatchProc(kAbout, AboutBoxDispatch);
  82.     SetIndDispatchProc(kHelp, HelpWindowDispatch);
  83.     SetIndDispatchProc(kAboutMSG, AboutMSGBoxDispatch);
  84.     
  85.     /* call window dispatch routines with "startup" message */
  86.     CallIndDispatchProc(kAbout, kStartup, 0L);
  87.     CallIndDispatchProc(kAboutMSG, kStartup, 0L);
  88.     
  89.     return TRUE;
  90. }
  91.  
  92. void OpenTheIndWindow(short index)
  93. {
  94.     WindowPtr        theWindow;
  95.     
  96.     if (!((**gTheWindowData[index]).theWindowPtr))        /* if window exists, we'll just update it (see below) */
  97.     {
  98.         if (CallIndDispatchProc(index, kInitialize, 0L)==kFailure)
  99.         {        /* default is to center window on main screen */
  100.             (**(gTheWindowData[index])).initialTopLeft.h =
  101.                 gMainScreenBounds.left + (((gMainScreenBounds.right -
  102.                 gMainScreenBounds.left) - (**(gTheWindowData[index])).windowWidth) / 2);
  103.             (**(gTheWindowData[index])).initialTopLeft.v =
  104.                 gMainScreenBounds.top + (((gMainScreenBounds.bottom -
  105.                 gMainScreenBounds.top) - (**(gTheWindowData[index])).windowHeight) / 2);
  106.         }
  107.         
  108.         (**(gTheWindowData[index])).windowBounds.left=
  109.             (**(gTheWindowData[index])).initialTopLeft.h;
  110.         
  111.         (**(gTheWindowData[index])).windowBounds.top=
  112.             (**(gTheWindowData[index])).initialTopLeft.v;
  113.             
  114.         if (((**(gTheWindowData[index])).windowType==noGrowDocProc) ||
  115.             ((**(gTheWindowData[index])).windowType==documentProc) ||
  116.             ((**(gTheWindowData[index])).windowType==movableDBoxProc) ||
  117.             ((**(gTheWindowData[index])).windowType==zoomDocProc) ||
  118.             ((**(gTheWindowData[index])).windowType==zoomNoGrow) ||
  119.             ((**(gTheWindowData[index])).windowType==rDocProc))
  120.                 (**(gTheWindowData[index])).windowBounds.top += 9;    /* compensate for title */
  121.         
  122.         /* don't put window over menu bar */
  123.         if ((**(gTheWindowData[index])).windowBounds.top < GetMBarHeight()+1)
  124.             (**(gTheWindowData[index])).windowBounds.top = GetMBarHeight()+1;
  125.         
  126.         (**(gTheWindowData[index])).windowBounds.bottom =
  127.             (**(gTheWindowData[index])).windowBounds.top +
  128.             (**(gTheWindowData[index])).windowHeight;
  129.         
  130.         (**(gTheWindowData[index])).windowBounds.right =
  131.             (**(gTheWindowData[index])).windowBounds.left +
  132.             (**(gTheWindowData[index])).windowWidth;
  133.         
  134.         KillOffscreen(index);        /* kill offscreen bitmaps that are left over */
  135.         
  136.         if (gHasColorQD)
  137.         {
  138.             /* create the color window with our specs, see IM Essentials 4-79ff */
  139.             (**gTheWindowData[index]).theWindowPtr=
  140.                 NewCWindow(0L, &((**(gTheWindowData[index])).windowBounds),
  141.                 (**(gTheWindowData[index])).windowTitle, FALSE,
  142.                 (**(gTheWindowData[index])).windowType, (WindowPtr)-1L,
  143.                 (**(gTheWindowData[index])).hasCloseBox,
  144.                 (unsigned long)gTheWindowData[index]);
  145.         }
  146.         else
  147.         {
  148.             /* create the B/W window with our specs, see IM Essentials 4-82ff */
  149.             (**gTheWindowData[index]).theWindowPtr=
  150.                 NewWindow(0L, &((**(gTheWindowData[index])).windowBounds),
  151.                 (**(gTheWindowData[index])).windowTitle, FALSE,
  152.                 (**(gTheWindowData[index])).windowType, (WindowPtr)-1L,
  153.                 (**(gTheWindowData[index])).hasCloseBox,
  154.                 (unsigned long)gTheWindowData[index]);
  155.         }
  156.     }
  157.     
  158.     if ((theWindow=GetIndWindowGrafPtr(index))!=0L)
  159.     {
  160.         ShowWindow(theWindow);            /* immediately show this new window */
  161.         SelectWindow(theWindow);        /* immediately select this new window */
  162.         SetPort(theWindow);            /* important! for TE info to stick*/
  163.         /* call window's dispatch routine to alert it that it's open now */
  164.         CallIndDispatchProc(index, kOpen, 0L);
  165.         UpdateTheWindow((ExtendedWindowDataHandle)gTheWindowData[index]);    /* immediately update this new window */
  166.     }
  167.     else HandleError(kNoMemory, FALSE);            /* if unsuccessful, display error */
  168. }
  169.  
  170. void GetMainScreenBounds(void)
  171. {
  172.     gMainScreenBounds = screenBits.bounds;        /* low-mem global */
  173.     gMainScreenBounds.top += GetMBarHeight();    /* don't include menu bar */
  174. }
  175.  
  176. short GetBiggestDeviceDepth(ExtendedWindowDataHandle theData)
  177. {
  178.     short            index;
  179.     Rect            tempRect;
  180.     long            biggestSize;
  181.     long            tempSize;
  182.     GDHandle        thisHandle, gBiggestDevice;
  183.     
  184.     if (!gHasColorQD)
  185.         return 1;
  186.     
  187.     index=(**theData).windowIndex;
  188.     
  189.     if (!GetIndWindowGrafPtr(index))
  190.         return (**(**GetMainDevice()).gdPMap).pixelSize;
  191.     
  192.     thisHandle = GetDeviceList();
  193.     gBiggestDevice = 0L;
  194.     biggestSize = 0L;
  195.     
  196.     while (thisHandle)
  197.     {
  198.         if (TestDeviceAttribute(thisHandle, screenDevice) &&
  199.             TestDeviceAttribute(thisHandle, screenActive))
  200.         {
  201.             if (SectRect(&(GetIndWindowGrafPtr(index)->portRect), &((**thisHandle).gdRect),
  202.                     &tempRect))
  203.             {
  204.                 if (biggestSize < (tempSize = ((long)(tempRect.bottom - tempRect.top))*
  205.                     ((long)(tempRect.right - tempRect.left))))
  206.                 {
  207.                     biggestSize = tempSize;
  208.                     gBiggestDevice = thisHandle;
  209.                 }
  210.             }
  211.         }
  212.         thisHandle = GetNextDevice(thisHandle);
  213.     }
  214.     
  215.     return (gBiggestDevice) ? (**(**gBiggestDevice).gdPMap).pixelSize : 1;
  216. }
  217.  
  218. short GetWindowDepth(ExtendedWindowDataHandle theData)
  219. {
  220.     short            index;
  221.     
  222.     index=(**theData).windowIndex;
  223.     /* if Color Quickdraw is not available, the depth must be 1. */
  224.     /* if Color Quickdraw is available and the window exists, return the window's
  225.        GWorld's graphics device's pixel map's pixel depth */
  226.     /* if Color Quickdraw is available and the window does not exist, return the
  227.        pixel depth of the main screen */
  228.     return (gHasColorQD) ? ((GetIndWindowGrafPtr(index)) ?
  229.             (**(**(GetGWorldDevice(gTheGWorld[index]))).gdPMap).pixelSize :
  230.             (**(**GetMainDevice()).gdPMap).pixelSize) : 1;
  231. }
  232.  
  233. Boolean WindowIsColor(ExtendedWindowDataHandle theData)
  234. {
  235.     short            index;
  236.     
  237.     index=(**theData).windowIndex;
  238.     return (gHasColorQD) ? ((GetWindowDepth(theData)>8) ? TRUE :
  239.         TestDeviceAttribute(GetGWorldDevice(gTheGWorld[index]), gdDevType)) : FALSE;
  240. }
  241.  
  242. void UpdateTheWindow(ExtendedWindowDataHandle theData)
  243. {
  244.     short            index;
  245.     long            offRowBytes, sizeOfOff;
  246.     unsigned long    updateResult;
  247.     Boolean            isColor;
  248.     PixMapHandle    thePixMapHandle;
  249.     short            TEindex;
  250.     
  251.     index=(**theData).windowIndex;
  252.     gBoundsRect[index]=GetIndWindowGrafPtr(index)->portRect;
  253.     OffsetRect(&gBoundsRect[index], -gBoundsRect[index].left, -gBoundsRect[index].top);
  254.  
  255.     if (gHasColorQD)    /* w/o Color Quickdraw, GWorlds may not be supported */
  256.     {
  257.         if (gTheGWorld[index]==0L)        /* create new graphics world if none exists */
  258.         {
  259.             /* try to create new graphics world; display error if unsuccessful */
  260.             if (NewGWorld(&gTheGWorld[index],
  261.                 (GetBiggestDeviceDepth(theData)>=(**theData).maxDepth) ?
  262.                 (**theData).maxDepth : 0, &gBoundsRect[index], 0L, 0L, 0)!=0)
  263.             {
  264.                 HandleError(kNoMemory, TRUE);        /* quits */
  265.             }
  266.             
  267.             (**theData).windowDepth=GetWindowDepth(theData);
  268.             NoPurgePixels(GetGWorldPixMap(gTheGWorld[index]));    /* never purge our pixmap! */
  269.             updateResult=1;
  270.         }
  271.         else updateResult=0;
  272.         
  273.         GetGWorld(¤tGWorld, ¤tGDHandle);    /* get current settings */
  274.         LockPixels(thePixMapHandle=GetGWorldPixMap(gTheGWorld[index]));    /* important!  copybits may move mem */
  275.         /* update offscreen graphics world, compensating for change in pixel depth */
  276.         updateResult|=(unsigned long)UpdateGWorld(&gTheGWorld[index],
  277.             (GetBiggestDeviceDepth(theData)>=(**theData).maxDepth) ? (**theData).maxDepth :
  278.             0, &gBoundsRect[index], 0L, 0L, 0);
  279.         SetGWorld(gTheGWorld[index], 0L);                /* set to our offscreen gworld */
  280.         
  281.         isColor=WindowIsColor(theData);
  282.         if (isColor!=(**theData).isColor)
  283.         {
  284.             (**theData).isColor=isColor;
  285.             updateResult=1;
  286.         }
  287.         
  288.         if ((updateResult!=0L) || ((**theData).windowDepth!=GetWindowDepth(theData)))
  289.         {
  290.             (**theData).windowDepth=GetWindowDepth(theData);    /* save new depth */
  291.             (**theData).offscreenNeedsUpdate=TRUE;                /* we'll need to redraw */
  292.             CallDispatchProc(theData, kChangeDepth, 0L);
  293.         }
  294.     }
  295.     else    /* deal with (guaranteed) B/W bitmaps manually */
  296.     {
  297.         if (gBWGrafPtr[index]==0L)    /* create new offscreen bitmap if none exists */
  298.         {
  299.             gBWGrafPtr[index]=&gBWGrafPort[index];
  300.             OpenPort(gBWGrafPtr[index]);    /* make a new port */
  301.             
  302.             /* calculate the size of the offscreen bitmap from the boundsrect */
  303.             offRowBytes=(((gBoundsRect[index].right-gBoundsRect[index].left)+15)>>4)<<1;
  304.             sizeOfOff=(long)(gBoundsRect[index].bottom-gBoundsRect[index].top)*offRowBytes;
  305.             
  306.             gBWBitMap[index]=NewPtr(sizeOfOff);        /* allocate space for bitmap */
  307.             if (gBWBitMap[index]==0L)                /* abort if unsuccessful */
  308.             {
  309.                 ClosePort(gBWGrafPtr[index]);        /* cleaning up... */
  310.                 gBWGrafPtr[index]=0L;
  311.                 HandleError(kNoMemory, TRUE);        /* displaying error... */
  312.             }
  313.             
  314.             gBWGrafPort[index].portBits.baseAddr=gBWBitMap[index];    /* --> our bitmap */
  315.             gBWGrafPort[index].portBits.rowBytes=offRowBytes;        /* bitmap size */
  316.             gBWGrafPort[index].portBits.bounds=                        /* bitmap bounds */
  317.                 gBWGrafPort[index].portRect=gBoundsRect[index];
  318.             
  319.             SetPort(gBWGrafPtr[index]);
  320.             (**theData).offscreenNeedsUpdate=TRUE;
  321.         }
  322.         else SetPort(gBWGrafPtr[index]);            /* set port for subsequent drawing */
  323.     }    
  324.     
  325.     if ((**theData).offscreenNeedsUpdate)            /* if we need to redraw */
  326.     {
  327.         (**theData).offscreenNeedsUpdate=FALSE;        /* not anymore */
  328.         /* call window's dispatch and tell it to redraw itself */
  329.         CallDispatchProc(theData, kUpdate, GetWindowDepth(theData));
  330.     }
  331.     
  332.     if (gHasColorQD)
  333.         SetGWorld(currentGWorld, currentGDHandle);    /* restore old settings */
  334.     
  335.     SetPort(GetWindowGrafPtr((WindowDataHandle)theData));
  336.     
  337.     /* copy offscreen bitmap from graphics world or bitmap to onscreen window */
  338.     if (CallDispatchProc(theData, kCopybits, gHasColorQD ? (unsigned long)gTheGWorld[index] :
  339.         (unsigned long)gBWGrafPtr[index])==kFailure)
  340.         CopyBits(gHasColorQD ? &(((GrafPtr)gTheGWorld[index])->portBits) :
  341.                     &(gBWGrafPtr[index]->portBits), &(GetIndWindowGrafPtr(index)->portBits),
  342.                     &gBoundsRect[index], &gBoundsRect[index], 0, 0L);
  343.     
  344.     for (TEindex=0; TEindex<MAX_TE_HANDLES; TEindex++)
  345.     {
  346.         if ((**theData).hTE[TEindex]!=0L)
  347.             TEUpdate(&(GetIndWindowGrafPtr(TEindex)->portRect), (**theData).hTE[TEindex]);
  348.     }
  349.  
  350.     if (gHasColorQD)
  351.         UnlockPixels(thePixMapHandle);    /* remember we locked these? */
  352.     
  353.     ValidRect(&(GetIndWindowGrafPtr(index)->portRect));        /* so we don't reupdate */
  354.     
  355.     if (index!=kMainWindow)
  356.         KillOffscreen(index);
  357. }
  358.  
  359. Boolean CloseTheWindow(ExtendedWindowDataHandle theData)
  360. {
  361.     short            index;
  362.     
  363.     index=(**theData).windowIndex;
  364.     
  365.     /* if the window's dispatch cancels the close, abort */
  366.     if (CallDispatchProc(theData, kClose, 0L)==kCancel)
  367.         return FALSE;
  368.     
  369.     DisposeWindow(GetIndWindowGrafPtr(index));    /* get rid of the actual window in memory */
  370.     (**gTheWindowData[index]).theWindowPtr=0L;    /* so _we_ know the window doesn't exist */
  371.     KillOffscreen(index);                /* kill offscreen bitmaps left over */
  372.     
  373.     /* tell window's dispatch that it's disposed of now */
  374.     CallDispatchProc(theData, kDispose, 0L);
  375.     
  376.     return TRUE;    /* successful close */
  377. }
  378.  
  379. Boolean CloseTheIndWindow(short index)
  380. {
  381.     return CloseTheWindow(gTheWindowData[index]);
  382. }
  383.  
  384. PicHandle DrawThePicture(PicHandle thePict, short whichPict, short x, short y)
  385. /* a standard routine for loading a picture (if necessary) and then drawing it */
  386. {
  387.     Rect            temp;
  388.     
  389.     if (thePict==0L)        /* get it if it doesn't exist */
  390.         thePict=(PicHandle)GetPicture(whichPict);
  391.     
  392.     HLock((Handle)thePict);        /* lock it down for dereferencing to get picture bounds */
  393.     temp.top=y;
  394.     temp.left=x;
  395.     temp.bottom=temp.top+(**thePict).picFrame.bottom-(**thePict).picFrame.top;
  396.     temp.right=temp.left+(**thePict).picFrame.right-(**thePict).picFrame.left;
  397.     DrawPicture(thePict, &temp);    /* draw picture at (x,y) */
  398.     HUnlock((Handle)thePict);        /* unlock for better memory management */
  399.     return thePict;
  400. }
  401.  
  402. PicHandle ReleaseThePict(PicHandle thePict)
  403. {
  404.     if (thePict!=0L)    /* if exists, release it */
  405.         ReleaseResource((Handle)thePict);
  406.     return 0L;
  407. }
  408.  
  409. Boolean SetPortToOffscreen(WindowDataHandle theData)
  410. {
  411.     short            index;
  412.     
  413.     index=(**theData).windowIndex;
  414.     
  415.     if (gHasColorQD)
  416.     {
  417.         if (gTheGWorld[index]==0L)
  418.             return FALSE;
  419.         GetGWorld(¤tGWorld, ¤tGDHandle);    /* get current settings */
  420.         LockPixels(GetGWorldPixMap(gTheGWorld[index]));    /* important!  copybits may move mem */
  421.         SetGWorld(gTheGWorld[index], 0L);
  422.     }
  423.     else
  424.     {
  425.         if (gBWGrafPtr[index]==0L)
  426.             return FALSE;
  427.         SetPort(gBWGrafPtr[index]);
  428.     }
  429.     
  430.     return TRUE;
  431. }
  432.  
  433. void RestorePortToScreen(WindowDataHandle theData)
  434. {
  435.     if (gHasColorQD)
  436.     {
  437.         SetGWorld(currentGWorld, currentGDHandle);    /* restore old settings */
  438.         UnlockPixels(GetGWorldPixMap(gTheGWorld[(**theData).windowIndex]));
  439.     }
  440.     
  441.     SetPort(GetWindowGrafPtr(theData));
  442. }
  443.  
  444. GrafPtr GetOffscreenGrafPtr(WindowDataHandle theData)
  445. {
  446.     if (gHasColorQD)
  447.         return (GrafPtr)gTheGWorld[(**theData).windowIndex];
  448.     else
  449.         return gBWGrafPtr[(**theData).windowIndex];
  450. }
  451.  
  452. GrafPtr GetIndOffscreenGrafPtr(short index)
  453. {
  454.     return GetOffscreenGrafPtr((WindowDataHandle)gTheWindowData[index]);
  455. }
  456.  
  457. GrafPtr GetWindowGrafPtr(WindowDataHandle theData)
  458. {
  459.     return (GrafPtr)((**theData).theWindowPtr);
  460. }
  461.  
  462. GrafPtr GetIndWindowGrafPtr(short index)
  463. {
  464.     return GetWindowGrafPtr((WindowDataHandle)gTheWindowData[index]);
  465. }
  466.  
  467. ExtendedWindowDataHandle GetIndWindowDataHandle(short index)
  468. {
  469.     return gTheWindowData[index];
  470. }
  471.  
  472. void SetIndDispatchProc(short index, ProcPtr theProc)
  473. {
  474.     (**gTheWindowData[index]).dispatchProc=theProc;
  475. }
  476.  
  477. short CallIndDispatchProc(short index, short theMessage, unsigned long misc)
  478. {
  479.     return ((**(gTheWindowData[index])).dispatchProc)((WindowDataHandle)gTheWindowData[index], theMessage, misc);
  480. }
  481.  
  482. short CallDispatchProc(ExtendedWindowDataHandle theData, short theMessage, unsigned long misc)
  483. {
  484.     return ((**theData).dispatchProc)((WindowDataHandle)theData, theMessage, misc);
  485. }
  486.  
  487. void SetIndWindowTitle(short index, Str255 theTitle)
  488. {
  489.     Mymemcpy((Ptr)((**(gTheWindowData[index])).windowTitle), (Ptr)theTitle, theTitle[0]+1);
  490. }
  491.  
  492. void KillOffscreen(short index)
  493. {
  494.     if (gTheGWorld[index]!=0L)
  495.         DisposeGWorld(gTheGWorld[index]);
  496.     if (gBWGrafPtr[index]!=0L)
  497.         DisposePtr((Ptr)gBWGrafPtr[index]);
  498.     gTheGWorld[index]=0L;
  499.     gBWGrafPtr[index]=0L;
  500.     (**(gTheWindowData[index])).offscreenNeedsUpdate=TRUE;
  501. }
  502.  
  503. void ShutDownTheGraphics(void)
  504. {
  505.     short            i;
  506.     
  507.     /* send shutdown messages to the shell's windows */
  508.     CallIndDispatchProc(kAbout, kShutdown, 0L);
  509.     CallIndDispatchProc(kHelp, kShutdown, 0L);
  510.     CallIndDispatchProc(kAboutMSG, kShutdown, 0L);
  511.     
  512.     for (i=0; i<NUM_WINDOWS; i++)
  513.     {
  514.         KillOffscreen(i);
  515.         if (GetIndWindowGrafPtr(i)!=0L)
  516.             DisposeWindow((**gTheWindowData[i]).theWindowPtr);
  517.         if (gTheWindowData[i]!=0L)
  518.             DisposeHandle((Handle)gTheWindowData[i]);
  519.     }
  520. }
  521.